package com.dcw.lixb.designmode.flyweight;

import java.util.HashMap;

/**
 * @author lixiaobin
 * @date 2020-07-23 15:34:04
 * @desc 描述信息
 */
public class ShapeFactory {
    private static final HashMap<String, Shape> circleMap = new HashMap<>();

    public static Shape getCircle(String color) {
        Circle circle = (Circle) circleMap.get(color);
        if (circle == null) {
            circle = new Circle(color);
            circleMap.put(color, circle);
            System.out.println("create circle of color : "+color);
        }

        return circle;
    }
}
